<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>查询</title>
    <link href="res/style.css" rel="stylesheet">
    <script src="js/axios.min.js"></script>
    <script src="js/vue.min.js"></script>
</head>
<body>
<div id="app" class="flex">
    <main>
        <header class="flex">
            <div>
                <h3>源辰银行</h3>
                <small>ycinfo bank</small>
            </div>
            <div id="contact">
                <div>客服电话: 8888</div>
                <div>网址: www.ycinfo.bank.com</div>
            </div>
        </header>
        <div class="msg">
            倒计时: <h2>32</h2> 秒
        </div>
        <div id="pane" class="flex">
            <div class="btns">
                <a class="hidden">占位</a>
                <a class="hidden">占位</a>
                <a class="hidden">占位</a>
            </div>
            <div id="info">
                <h2>查询服务</h2>
                <form action="main.html">
                    <table>
                        <tr><th>序号</th><th>时间</th><th>交易金额</th><th>交易费</th><th>备注</th></tr>
                        <tr v-for="item in list"><td>{{item.id}}</td><td>{{item.optime}}</td><td>{{item.opmoney}}</td><td>{{item.charge}}</td><td>{{item.remark}}</td></tr>
                    </table>
                    <div id="page" class="right">
                        <a @click="pre">上一页</a> {{current}}/{{total}} <a @click="next">下一页</a>
                    </div>
                </form>
            </div>
            <div class="btns">
                <a class="hidden">占位</a>
                <a class="hidden">占位</a>
                <a class="hidden">占位</a>
                <a href="main.html" class="right">返回</a>
            </div>
        </div>
    </main>>
</div>
</body>
</html>

<script>
    new Vue({
        el: "#app",
        data: {
            list: [],
            current: 1,
            total: 0,
            size: 5
        },
        methods: {
            pre(){
                this.current--
                if (this.current < 1) {
                    this.current = 1
                }
                this.queryByPage()
            },
            next(){
                this.current++
                if (this.current > this.total) {
                    this.current = this.total
                }
                this.queryByPage()
            }
            ,
            queryByPage(){
                axios.get("bank/queryByPage?current=" + this.current + "&size=" + this.size).then(res => {
                    if (res.data.code === 200) {
                        this.list = res.data.list.records
                        this.total = res.data.list.total
                        this.total = Math.ceil(this.total / this.size)
                    }
                })
            }
        },
        mounted() {
            this.queryByPage()
        }
    })
</script>
